<template>
  <div class="list">
    <page-header type="page"></page-header>
    <planting :lbimgList="lbimgList"></planting>
    <article class="spice-article spice-article-list-filter e-loading-none">
      <div class="spice-list-filter-box-slot">
        <div class="spice-breadcrumb">
          <ul class="spice-list-inline">
            <li>
              <a>{{ oneTypeName }}</a>
            </li>
            <li class="spice-divider">·</li>
            <li>
              <span style="font-size: 12px">{{ twoTypeName }}</span>
            </li>
          </ul>
        </div>
      </div>
    </article>
    <div class="spice-container">
      <div class="spice-gutter">
        <div class="product-box">
          <div class="product-cell-cont">
            <div
              class="spice-product-tiles-slot"
              v-for="(goods, index) in goodsList"
              :key="index"
            >
              <div
                class="product-tiles-box"
                :class="cardIndex == index ? 'slot-product-tiles-active' : ''"
                @mouseenter.stop="cardMove(index)"
                @mouseleave.stop="cardOut(index)"
              >
                <i
                  class="spice-icon spice-icon-recent-browsing-collection e-spice-wishlist-add"
                ></i>
                <template v-if="cardIndex == index">
                  <div class="swiper-body fadeIn animated">
                    <div class="spice-item-grid-img-box">
                      <el-carousel :interval="4000" class="Home-lbimg-carousel">
                        <el-carousel-item
                          v-for="url in goods.goodsImgList"
                          :key="url"
                        >
                          <img :src="url" class="medium" width="100%" />
                        </el-carousel-item>
                      </el-carousel>
                    </div>
                    <div class="spice-item-grid-info">
                      <h2>{{ goods.goodsName }}</h2>
                      <div class="spice-item-grid-price">
                        <p><del></del></p>
                        <p>￥{{ goods.goodsPrice }}</p>
                      </div>
                      <div
                        class="spice-item-grid-buyNow"
                        @click="goInfo(goods.goodsId)"
                      >
                        <span>立即购买</span>
                        <i class="svg-default-textlink"></i>
                      </div>
                    </div>
                  </div>
                </template>
                <template v-else>
                  <div class="spice-item-grid-img-box">
                    <img :src="goods.goodsImg" />
                  </div>
                </template>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "list",
  data() {
    return {
      lbimgList: [
        {
          id: 1,
          url:
            "https://res.gucci.cn/resources//2020/12/16/16080836597929751_content_HeroBigStandard_1600x760_1607701503_HeroBigStandard_Foundation-Face-02-new_001_Default.jpg",
        },
        {
          id: 2,
          url:
            "https://res.gucci.cn/resources//2020/12/16/16080836597929751_content_HeroBigStandard_1600x760_1607701503_HeroBigStandard_Foundation-Face-02-new_001_Default.jpg",
        },
      ],
      cardIndex: -1,
      twoId: -1,
      goodsList: [],
      goInfo(goodsId) {
        this.$router.push({ path: `/Info?goodsId=${goodsId}` });
      },
    };
  },
  created() {
    this.twoId = this.$route.query.twoId;
    this.twoTypeName = this.$route.query.twoTypeName;
    this.oneTypeName = this.$route.query.oneTypeName;
    this.$api
      .getGoodsByTwo({
        twoId: this.twoId,
      })
      .then((res) => {
        if (res.code) {
          this.goodsList = res.goodsList;
        }
      });
  },
  methods: {
    cardMove(index) {
      this.cardIndex = index;
    },
    cardOut() {
      this.cardIndex = -1;
    },
  },
};
</script>

<style lang="scss">
.list {
  .el-carousel__container {
    height: 23vw;
  }
  .spice-list-filter-box-slot {
    z-index: 9;
    height: 60px;
    background: #fff;
    position: relative;
    .spice-breadcrumb {
      height: 100%;
      padding-left: 30px;
      font-size: 16px;
      .spice-list-inline {
        display: flex;
        align-items: center;
        height: 100%;
      }
      .spice-divider {
        margin: 0 13px;
      }
      a,
      span {
        color: #999;
        font-size: 12px;
        letter-spacing: 0;
      }
    }
  }
  .spice-gutter {
    padding: 0 15px 15px;
    background-color: #fff;
    position: relative;
    .product-box {
      background-color: #e6e6e6;
      width: 100%;
      margin: 0 auto;
      .product-cell-cont {
        .spice-product-tiles-slot {
          height: 30vw;
          display: inline-block;
          width: 25%;
          vertical-align: middle;
          border-right: 1px solid #fff;
          border-bottom: 1px solid #fff;
          position: relative;
          .spice-item-grid-img-box {
            height: 30vw;
            padding-top: 80px;
            width: 100%;
            /* max-width: 470px; */
            margin: 0 auto;
            position: relative;
            overflow: hidden;
          }
        }
      }
    }
  }
  .product-tiles-box {
    /* height: 438px; */
    &.slot-product-tiles-active {
      background-color: #fff;
    }
  }
  .swiper-body {
    position: relative;
    z-index: 999;
    height: 500px;
    background: #fff;
    .spice-item-grid-info {
      text-align: center;
      min-height: auto;
      height: auto;
      margin: 0 auto;
      padding: 20px 0px;
      background: #fff;
      & > h2 {
        font-size: 14px;
        color: #313131;
        letter-spacing: 1px;
        line-height: 20px;
        height: auto;
        padding: 12px 0;
        position: relative;
      }
      .spice-item-grid-buyNow {
        margin: 16px 0 0;
        position: relative;
        cursor: pointer;
        span {
          font-family: FuturaLT-Book, GucciChinese;
          margin-right: 5px;
          font-size: 12px;
          color: #1b1b1b;
          letter-spacing: 1px;
          display: inline-block;
          line-height: 12px;
        }
      }
      .spice-item-grid-price {
        margin-bottom: 0;
        p {
          font-family: FuturaLT-Book, GucciChinese;
          font-size: 14px;
          color: #999;
          letter-spacing: 1px;
          line-height: 14px;
        }
      }
    }
  }
}
</style>